package com.example.ploy4j.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {

    @GetMapping("/login")
    public String loginPage(@RequestParam(value = "error", required = false) String error,
                          @RequestParam(value = "logout", required = false) String logout,
                          Model model) {
        if (error != null) {
            model.addAttribute("loginError", "无效的用户名或密码。");
        }
        if (logout != null) {
            model.addAttribute("logoutMessage", "您已成功注销。");
        }
        return "login"; // Path to login.html Thymeleaf template
    }
} 